package com.example.qxfw.qxxx.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.qx.MsgMediumSmallScale;
import com.example.qxfw.common.entity.qx.SmallScaleStation;
import com.example.qxfw.common.entity.qx.WaterRain;
import com.example.qxfw.common.entity.qx.WaterStation;
import com.example.qxfw.common.entity.xt.ContourSetting;
import com.example.qxfw.qxxx.service.ContourSettingService;
import com.example.qxfw.qxxx.service.WaterRainService;
import com.example.qxfw.qxxx.service.WaterStationService;
import com.example.qxfw.rcyw.service.SmallScaleStationService;
import com.example.qxfw.ybzz.service.MsgMediumSmallScaleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "气象信息-雨情接口")
@RestController
@CrossOrigin
@RequestMapping("/yq")
public class yqController {

    @Autowired
    private SmallScaleStationService smallScaleStationService;

    @Autowired
    private MsgMediumSmallScaleService msgMediumSmallScaleService;

    @Autowired
    private ContourSettingService contourSettingService;

    @Autowired
    private WaterStationService waterStationService;

    @Autowired
    private WaterRainService waterRainService;

    @ApiOperation("气象信息-雨情接口-获取站点名称")
    @GetMapping("/getSmallScaleStaionName")
    public SysResult getSmllScaleStationName(){
        return SysResult.success();
    }

    @ApiOperation("气象信息-雨情接口-获取站点信息")
    @GetMapping("/getSmallScaleStation1")
    public SysResult getSmallScaleStation1(String stationName){
        List<SmallScaleStation> list3 = smallScaleStationService.getList3(stationName);
        return SysResult.success(list3);
    }

    @ApiOperation("气象信息-雨情接口-获取站点信息")
    @GetMapping("/getSmallScaleStation2")
    public SysResult getSmallScaleStation2(){
        List<SmallScaleStation> list4 = smallScaleStationService.getList4();
        return SysResult.success(list4);
    }

    @ApiOperation("气象信息-雨情接口信息-单时段查询全部")
    @GetMapping("/getMsgMediumSmallScale1")
    public SysResult getMsgMediumSmallScale1(String observTime,String county){
        List<MsgMediumSmallScale> list = msgMediumSmallScaleService.getList3(observTime, county);
        return SysResult.success(list);
    }

    @ApiOperation("气象信息-雨情接口-单时段查询")
    @GetMapping("/getMsgMediumSmallScale2")
    public SysResult getMsgMediumSmallScale2(String observTime,String stationID){
        List<MsgMediumSmallScale> list = msgMediumSmallScaleService.getList4(observTime,stationID);
        return SysResult.success(list);
    }

    @ApiOperation("气象信息-雨情接口-多时段查询全部")
    @GetMapping("/getMsgMediumSmallScale3")
    public SysResult getMsgMediumSmallScale3(String observTime1,String observTime2,String county){
        List<MsgMediumSmallScale> list = msgMediumSmallScaleService.getList5(observTime1,observTime2,county);
        return SysResult.success(list);
    }

    @ApiOperation("气象信息-雨情接口-多时段查询")
    @GetMapping("/getMsgMediumSmallScale4")
    public SysResult getMsgMediumSmallScale4(String observTime1,String observTime2,String stationId){
        List<MsgMediumSmallScale> list = msgMediumSmallScaleService.getList6(observTime1,observTime2,stationId);
        return SysResult.success(list);
    }

    @ApiOperation("气象信息-雨情接口-获取站点名称")
    @GetMapping("/getStationNameByCounty")
    public SysResult getStationNameByCounty(String county){
        List<String> stationName = smallScaleStationService.getStationNameByCounty(county);
        return SysResult.success(stationName);
    }

    @ApiOperation("气象信息-雨情接口-获取站点名称")
    @GetMapping("getStaionNameByCity")
    public SysResult getStationNameByCity(String city){
        List<String> stationName = smallScaleStationService.getStationNameByCity(city);
        return SysResult.success(stationName);
    }

    @ApiOperation("气象信息-雨情接口-获取站点county")
    @GetMapping("/getCounty")
    public SysResult getCounty(){
        List<String> county = smallScaleStationService.getCounty();
        return SysResult.success(county);
    }

    @ApiOperation(("气象信息-雨情接口-更新MsgMediumSmallScale"))
    @GetMapping("/updateMsgMediumSmallScale")
    public SysResult updateMsgMediumSmallScale(MsgMediumSmallScale msgMediumSmallScale){
        Integer rows = msgMediumSmallScaleService.update(msgMediumSmallScale);
        return SysResult.success(rows);
    }

    @ApiOperation("气象信息-雨情接口-根据city查询站点信息")
    @GetMapping("/getSmallScaleStaionByCity")
    public SysResult getSmallScaleStaionByCity(String city){
        List<SmallScaleStation> list5 = smallScaleStationService.getList5(city);
        return SysResult.success(list5);
    }

    @ApiOperation("气象信息-雨情接口-获取等值线配置文件")
    @GetMapping("/getContourSetting")
    public SysResult getContourSetting(String elementType){
        List<ContourSetting> list = contourSettingService.getList(elementType);
        return SysResult.success(list);
    }

    @ApiOperation("气象信息-雨情接口-获取waterStaion")
    @GetMapping("/getWaterStaion")
    public SysResult getWaterStation(String addvcd){
        List<WaterStation> list1 = waterStationService.getList1(addvcd);
        return SysResult.success(list1);
    }

    @ApiOperation("气象信息-雨情接口-获取WaterStationStcd")
    @GetMapping("/getWaterStaionStcd")
    public SysResult getWaterStationStcd(String addvcd){
        List<String> stcd = waterStationService.getStcd(addvcd);
        return SysResult.success(stcd);
    }

    @ApiOperation("气象信息-雨情接口-获取WaterRain")
    @GetMapping("/getWaterRain")
    public SysResult getWaterRain(String tm1,String tm2,String sql,String stcds,String sql2,String sum){
        List<WaterRain> list = waterRainService.getList(tm1, tm2, sql, stcds, sql2, sum);
        return SysResult.success(list);
    }

}
